
#include <stdio.h>
#include <HighLevelMonitorConfigurationAPI.h>

#include "Win32Screen.h"

Win32Screen::Win32Screen()
{
	main_monitor_size_ = MncPoint(0, 0);
}

BOOL CALLBACK EnumDisplayMonitorCallback(HMONITOR monitor_handle, HDC hdc, LPRECT rectangle, LPARAM param)
{
	int width = (int)rectangle->right;
	int height = (int)rectangle->bottom;

	reinterpret_cast<Win32Screen*>(param)->SetMainMonitorSize(MncPoint(width, height));
	return TRUE;
}

MncPoint Screen::GetSize()
{
	MncPoint point_result;
	
	if(!EnumDisplayMonitors(NULL, NULL, EnumDisplayMonitorCallback, reinterpret_cast<LPARAM>(this)))
	{
		printf("Failed to enumerate Win32 displays\n");
		return point_result;
	}

	return main_monitor_size_;
}

void Win32Screen::SetMainMonitorSize(MncPoint size)
{
	main_monitor_size_ = size;
}